package ie.dkit.semanticPhotoWeb.client;

import ie.dkit.semanticPhotoWeb.client.dtos.AlbumDTO;
import ie.dkit.semanticPhotoWeb.client.dtos.CommentDTO;
import ie.dkit.semanticPhotoWeb.client.dtos.ImageDTO;
import ie.dkit.semanticPhotoWeb.client.dtos.InterestDTO;
import ie.dkit.semanticPhotoWeb.client.dtos.PersonDTO;
import ie.dkit.semanticPhotoWeb.client.dtos.RelationDTO;
import ie.dkit.semanticPhotoWeb.client.dtos.TagDTO;

import java.util.List;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.ServiceDefTarget;

/**
 * @author Sebastian Ruehl
 * 
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place, Suite 330, Boston, MA 02111-1307 USA
 */
public interface ClientServerConnector extends RemoteService {

	public static final String SERVICE_URI = "/CSC";

	public static class Util {

		public static ClientServerConnectorAsync getInstance() {

			ClientServerConnectorAsync instance = (ClientServerConnectorAsync) GWT
					.create(ClientServerConnector.class);
			ServiceDefTarget target = (ServiceDefTarget) instance;
			target.setServiceEntryPoint(GWT.getModuleBaseURL() + SERVICE_URI);
			return instance;
		}
	}

	/**
	 * Add a comment to the corresponding image
	 * 
	 * @param imageDTO
	 * @param commentDTO
	 */
	public void addComment(ImageDTO imageDTO, CommentDTO commentDTO);

	/**
	 * Add a interest to the users profile
	 * 
	 * @param interestDTO
	 */
	public void addInterest(InterestDTO interestDTO);

	/**
	 * Add a relation to the Foaf of the current logged User to the Person
	 * spezified by person
	 * 
	 * @param person
	 */
	public void addKnowRelation(PersonDTO person);

	/**
	 * Add a tag to a image
	 * 
	 * @param imageDTO
	 * @param tagDTO
	 */
	public void addTag(ImageDTO imageDTO, TagDTO tagDTO);

	/**
	 * Delete a Album
	 * 
	 * @param albumDTO
	 */
	public void deleteAlbum(AlbumDTO albumDTO);

	/**
	 * Delete a Comment
	 * 
	 * @param commentDTO
	 */
	public void deleteComment(CommentDTO commentDTO);

	/**
	 * Delete a known Relation
	 * 
	 * @param personDTO
	 */
	public void deleteKnownRelation(PersonDTO personDTO);

	/**
	 * Delete a Image
	 * 
	 * @param imageDTO
	 */
	public void deleteImage(ImageDTO imageDTO);

	/**
	 * Delete a interestDTO
	 * 
	 * @param interestDTO
	 */
	public void deleteInterest(InterestDTO interestDTO);

	/**
	 * Delete a Relation
	 * 
	 * @param relationDTO
	 */
	public void deleteRelation(RelationDTO relationsDTO);

	/**
	 * Delete a Tag
	 * 
	 * @param tagDTO
	 */
	public void deleteTag(TagDTO tagDTO);

	/**
	 * Returns Album by it s Name
	 * 
	 * @param username
	 *            the username of the albums owner
	 * @param albumName
	 *            the album name
	 * @return
	 */
	public AlbumDTO getAlbumByName(String username, String albumName);

	/**
	 * Get the Album from a image
	 * 
	 * @param dto
	 * @return
	 */
	public AlbumDTO getAlbum(ImageDTO dto);

	/**
	 * Return the albumDTO of the current logged in User
	 * 
	 * @return List<AlbumDTO>
	 * @gwt.typeArgs <ie.dkit.semanticPhotoWeb.client.dtos.AlbumDTO>
	 */
	public List getAlbums();

	/**
	 * Return the album Icons of the username
	 * 
	 * @param username
	 *            the username ot the album owner
	 * @return List<AlbumDTO>
	 * @gwt.typeArgs <ie.dkit.semanticPhotoWeb.client.dtos.AlbumDTO>
	 */
	public List getAlbums(String username);

	/**
	 * Returns the Google Auth link to authenticate
	 * 
	 * @return
	 */
	public String getAuthLink();

	/**
	 * Return a List of Comments for a Image
	 * 
	 * @param imageDTO
	 * @return List<CommentDTO>
	 * @gwt.typeArgs <ie.dkit.semanticPhotoWeb.client.dtos.CommentDTO>
	 */
	public List getComments(ImageDTO imageDTO);

	/**
	 * 
	 * @param album
	 * @return List<ImageDTO>
	 * @gwt.typeArgs <ie.dkit.semanticPhotoWeb.client.dtos.ImageDTO>
	 */
	public List getImages(AlbumDTO albumDTO);

	/**
	 * Returns the image by its id
	 * 
	 * @param username
	 * @param albumName
	 * @param imageID
	 * @return
	 */
	public ImageDTO getImageByID(String username, String albumName,
			String imageID);

	/**
	 * Get a list of pictures where the image linking to
	 * 
	 * @return List<RelationDTO>
	 * @gwt.typeArgs <ie.dkit.semanticPhotoWeb.client.dtos.RelationDTO>
	 */
	public List getLinkedPictures(ImageDTO imageDTO);

	/**
	 * Get a list of pictures linking to this picture
	 * 
	 * @param imageDTO
	 * @return List<RelationDTO>
	 * @gwt.typeArgs <ie.dkit.semanticPhotoWeb.client.dtos.RelationDTO>
	 */
	public List getReferringPictures(ImageDTO imageDTO);

	/**
	 * Get a list of tags of the corresponding ImageDTO
	 * 
	 * @param imageDTO
	 * @return
	 * @gwt.typeArgs <ie.dkit.semanticPhotoWeb.client.dtos.TagDTO>
	 */
	public List getTags(ImageDTO imageDTO);

	/**
	 * Get a list of tags of the corresponding AlbumIcon
	 * 
	 * @param albumDTO
	 * @return
	 * @gwt.typeArgs <ie.dkit.semanticPhotoWeb.client.dtos.TagDTO>
	 */
	public List getTags(AlbumDTO albumDTO);

	/**
	 * Return the username of the current logged in user
	 * 
	 * @return
	 */
	public String getUserName();

	/**
	 * Get the userprofile of the current logged in User
	 * 
	 * @return the UserProfile
	 */
	public PersonDTO getUserProfile();

	/**
	 * Get the userprofile specified by username
	 * 
	 * @param username
	 * @return the UserProfile
	 */
	public PersonDTO getUserProfileByUserName(String username);

	/**
	 * reurns the List of the tags by the current logged in user
	 * 
	 * @return
	 * @gwt.typeArgs <ie.dkit.semanticPhotoWeb.client.dtos.TagDTO>
	 */
	public List getUserTags();

	/**
	 * reurns the List of the tags by the user defined by username
	 * 
	 * @param username
	 * @return
	 * @gwt.typeArgs <ie.dkit.semanticPhotoWeb.client.dtos.TagDTO>
	 */
	public List getUserTags(String username);

	/**
	 * purposes
	 * 
	 * @param id
	 * @return
	 */
	public String getRDFFileByPersonID(int id);

	/**
	 * Is loggedIn
	 */
	public boolean isLoggedIn();

	/**
	 * Link a picture to another picture
	 * 
	 * @param imageDTO1
	 *            first picture
	 * @param imageDTO2
	 *            second picture
	 * @param typ
	 *            kind of link (e.g friend, samePerson, etc)
	 */
	public void linkToOtherPicture(ImageDTO imageDTO1, ImageDTO imageDTO2,
			String typ);

	/**
	 * Login into the System
	 * 
	 * @param authSubToken
	 * @return the username
	 */
	public String login(String authSubToken);

	/**
	 * Logsout of the System
	 */
	public void logout();

	/**
	 * Update the Own User Profile
	 * 
	 * @param personDTO
	 */
	public void updateUserProfile(PersonDTO personDTO);

	/**
	 * Updates a summary from a picture
	 * 
	 * @param imageDTO
	 * @param summary
	 */
	public void updateSummary(ImageDTO imageDTO, String summary);

	/**
	 * Create a new album
	 * 
	 * @param albumTitle
	 * @param description
	 * @return true if successful
	 */
	public boolean newAlbum(String albumTitle, String description);

}
